package com.karry.yl.web.filing;

import com.karry.commons.Constants;
import com.karry.commons.base.SuperController;
import com.karry.commons.vo.JsonResponse;
import com.karry.yl.domain.filing.Filing;
import com.karry.yl.domain.mz.MzDepartment;
import com.karry.yl.service.filing.FilingService;
import com.karry.yl.service.mz.MzDepartmentService;
import org.ponly.fs.util.IOUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URLEncoder;

/**
 * 机构备案表现层
 *
 * @author Administrator
 */
@Controller
@RequestMapping("/filing")
public class FilingController extends SuperController {

    @Autowired
    private FilingService filingService;

    @Autowired
    MzDepartmentService mzDepartmentService;


    /**
     * 添加备案记录，更该机构的备案状态
     *
     * @param filing
     * @return
     */
    @RequestMapping("/filingSubmitted")
    @ResponseBody
    public JsonResponse filingSubmitted(Filing filing,HttpSession session) {
        try {
           /* //根基民政侷的id查詢民政局
            MzDepartment mzDepartment = mzDepartmentService.selectByCode(filing.getMzCode());
            filing.setMzName(mzDepartment.getDepartmentName());*/
            filing.setOrgId(currentUser.getOrgId());
            currOrganization.setFilingStart(1);
            session.setAttribute(Constants.SK_JG,currOrganization);
            filingService.filingSubmitted(filing, currentUser.getOrgId());
            return new JsonResponse(200, "成功");
        } catch (Exception e) {
            e.printStackTrace();
            return new JsonResponse(0, "失败");
        }

    }

}
